﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Common;
using Common.Views;

namespace ElectroSystem.Controllers
{
    public class UpdateFaultController : MenusController
    {
        //
        // GET: /UpdateFault/

        [Authorize]
        public ActionResult Index()
        {
            List<FaultView> logentries = new FaultsServ.FaultsServiceClient().GetAllLogEntires().ToList();

            List<SelectListItem> faultsList = new List<SelectListItem>();
            IList<FaultStatu> faults = new FaultsServ.FaultsServiceClient().GetAllFaultStatuses();
            foreach (FaultStatu f in faults)
            {
                faultsList.Add(new SelectListItem { Text = f.StatusName, Value = f.StatusID.ToString() });
            }
            ViewData["faultList"] = faultsList;
            return View("Index", logentries);
        }

        [HttpPost]
        public ActionResult UpdateFaultStatus(Guid OrderID, Guid faultID, string fDetails, int statusId)
        {
            new FaultsServ.FaultsServiceClient().UpdateFault(OrderID, faultID, fDetails, statusId);
            return RedirectToAction("Index", "Home");
        }
    }
}
